# $Id: Makefile 18 2009-08-14 08:34:22Z vic.fryzel $

NAME = bil
DOC = ../doc

all: interpreter_build compiler_build

interpreter_build: parser_build
	cd interpreter; make all; cd ..

compiler_build: parser_build
	cd compiler; make all; cd ..

parser_build:
	cd parser; make all; cd ..

dist: distreq $(NAME)-parser.jar $(NAME)-interpreter.jar $(NAME)-compiler.jar

distreq:
	cd $(DOC); make doc; cd ../src
	cp -R $(DOC) .

$(NAME)-parser.jar: all
	jar cfe $@ parser.Parser *

$(NAME)-interpreter.jar: all
	jar cfe $@ interpreter.Interpreter *

$(NAME)-compiler.jar: all
	jar cfe $@ compiler.Compiler *

clean:
	cd parser; make clean; cd ..
	cd interpreter; make clean; cd ..
	cd compiler; make clean; cd ..
	rm -Rf *.jar pj2* META-INF doc *.tmp

# Everything after this line is a work in progress.  Trying to build parser
# from pj2 grammar file.
Parser.java: # pj2
	if [ ! -e Parser.java ]; then \
		java -classpath $(CLASSPATH) -jar pj2.jar -Generate grammar.pj2 > Parser.tmp; \
		java -classpath $(CLASSPATH) -jar jay.jar Parser.tmp > Parser.java; \
	fi

jlex:
	if [ ! -e jlex-1.2.6.jar ]; then \
		wget -N http://www.cs.rit.edu/~ats/projects/lp2/wcs/JLex/jlex-1.2.6.jar; \
        fi

jay:
	if [ ! -e jay.jar ]; then \
		wget -N http://www.cs.rit.edu/~ats/projects/lp/doc/jay/doc-files/jay.jar; \
	fi
